/**
 * 算法：求一个字符串中出现频率最高的字符，以及次数
 * 
 * 缺陷：不能统计中文
*/


#include <iostream>
#include <unordered_map>
using namespace std;

pair<char, int> max_char(string input){
    if(input.size() == 0) return {' ', 0};
    char max_char;
    int max_count = INT_MIN;
    unordered_map<char, int> map;
    for(char c : input){
        cout<<c<<endl;
        map[c]++;
        if(map[c] > max_count){
            max_char = c;
            max_count = map[c];
        }
    }

    return {max_char, max_count};
}

int main(){
    string input = "3abbeffcbb中中东南西北中";
    pair<char, int> ret = max_char(input);
    cout<<"max_char, max_count: " << ret.first << "," << ret.second << endl;
    return 0;
}